package GoodsBaseService

import (
	"context"
	toolsDb "gdshop-font-api-go/library/tools/db"
	"strings"
	"time"
)

func GetGoodsThumbsByGoodsId(ctx context.Context, goodsId, photoUrlProfix string) []string {
	thumbsArr := []string{}
	array, err := toolsDb.GetUnSafaTableAddDeleteWhere(ctx, "goods_extend").Where(
		"goods_id = ?",
		goodsId).Cache(600*time.Second,
		"front:goods:GetGoodsThumbsByGoodsId_"+goodsId).Fields(
		"goods_thumbs").Value()
	if err != nil {
		return thumbsArr
	}
	tmps := strings.Split(array.String(), ",")
	for _, s := range tmps {
		if s == "" {
			continue
		}
		thumbsArr = append(thumbsArr, photoUrlProfix+s)
	}

	return thumbsArr
}
